package com.hx.setting.model;

import com.hx.setting.model.RoleModel.RoleTableField;

/**
 * -- ==== --
 * CREATE TABLE `hx_role` (
 * `id` bigint(255) NOT NULL,
 * `rolename` varchar(200) DEFAULT NULL COMMENT '角色名称',
 * `parentrole` varchar(255) DEFAULT NULL COMMENT '父角色继承(id:id:id)',
 * `depth` int(19) DEFAULT NULL COMMENT '角色继承深度',
 * `allowassignedrecordsto` tinyint(2) NOT NULL DEFAULT '1' COMMENT '是否允许角色继承',
 * PRIMARY KEY (`id`)
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8
 * -- ==== --
 * Generate Date : 2014-03-16
 * Generate Version : v3.0
 * Generate Name : Honey v3.1 Test
 * Generate User : THINK
 * JDK Version : 1.5
 */
public final class RoleModel extends GeneratedCriteria<RoleModel, RoleTableField>
{

	public static final String	TABLE_NAME		= "hx_role";

	public static final String	DATABASE_VENDOR	= "Mysql-5.5";

	/**
	 * parentrole字段被映射成枚举类型
	 */
	public enum ParentroleEnum implements FinalStructure
	{
		/** 
		 * id)
		 */
		ID( "父角色继承(id", "id)", false );

		/** 枚举值 */
		private final String	value;

		/** 枚举名称 */
		private final String	show;

		/** 是否是终态值,如果是改字段不可修改。 */
		private final boolean	fianlvalue;

		/** 
		 * 构造方法
		 * 
		 * @param  value {@code   Short}
		 * @param  show {@code   String}
		 * 
		 * @see    String
		 */
		private ParentroleEnum(String value, String show, boolean fianlvalue)
		{
			this.value = value;
			this.show = show;
			this.fianlvalue = fianlvalue;
		}

		/** 
		 * 通过枚举值获取枚举对象
		 * 
		 * @param  value {@code   Short} 获取枚举对象的值
		 * 
		 * @return {@code ParentroleEnum} 枚举对象
		 * 
		 */
		public static final ParentroleEnum getInstance(String value)
		{
			ParentroleEnum[] enums = ParentroleEnum.values();
			for ( ParentroleEnum e : enums )
				if ( e.value.equals( value ) ) return e;
			throw new RuntimeException( "[" + value + "]在ParentroleEnum对象中是一个未知的枚举值. " );
		}

		/** 
		 * 获取枚举值(表示值)
		 * 
		 * @return {@code  Short}
		 */
		public final String getValue()
		{
			return this.value;
		}

		/** 
		 * 获取枚举显示名称
		 * 
		 * @return {@code  String} 枚举显示名称
		 */
		public final String getShow()
		{
			return this.show;
		}

		public final boolean isFinal()
		{
			return fianlvalue;
		}

		/** 
		 * 值域范围
		 * 
		 * @return {@code  String[]} 返回值域数组
		 */
		public static final String[] domain()
		{
			return new String[]
			{ "父角色继承(id", };
		}

		/** 
		 * to string
		 * 
		 * @return {@code  String}
		 */
		@Override
		public final String toString()
		{
			return String.valueOf( this.value );
		}
	}

	/**
	 * 
	 * 数据库字段枚举
	 */
	public enum RoleTableField implements TableField
	{
		/** 
		 * id
		 */
		ID( new String[]
		{ "id", "id", "id " } ),
		/** 
		 * 角色名称
		 */
		ROLENAME( new String[]
		{ "rolename", "rolename", "角色名称 " } ),
		/** 
		 * 父角色继承(id:id:id)
		 */
		PARENTROLE( new String[]
		{ "parentrole", "parentrole", "父角色继承(id:id:id)" } ),
		/** 
		 * 角色继承深度
		 */
		DEPTH( new String[]
		{ "depth", "depth", "角色继承深度 " } ),
		/** 
		 * 是否允许角色继承
		 */
		ALLOWASSIGNEDRECORDSTO( new String[]
		{ "allowassignedrecordsto", "allowassignedrecordsto", "是否允许角色继承 " } );

		/** 数据库字段名称 */
		private final String	value;

		/** 映射到java属性名称 */
		private final String	property;

		/** 数据库字段注释 */
		private final String	show;

		/** 
		 * 
		 * @param  value {@code   String}
		 * 
		 * @see    String
		 */
		private RoleTableField(String args[])
		{
			this.value = args[0];
			this.property = args[1];
			this.show = args[2];
		}

		public static final RoleTableField getInstance(String property)
		{
			RoleTableField answer = null;
			if ( property != null )
			{
				int hash = property.hashCode();
				switch ( hash )
				{
					case 3355 : //id,id 
						answer = ID;
						break;
					case -265826303 : //rolename,角色名称 
						answer = ROLENAME;
						break;
					case -243784672 : //parentrole,父角色继承(id:id:id)
						answer = PARENTROLE;
						break;
					case 95472323 : //depth,角色继承深度 
						answer = DEPTH;
						break;
					case 533100038 : //allowassignedrecordsto,是否允许角色继承 
						answer = ALLOWASSIGNEDRECORDSTO;
						break;
				}
			}
			return answer;
		}

		/** 
		 * 获取数据库字段名称
		 * 
		 * @return {@code  Short}
		 */
		@Override
		public final String getValue()
		{
			return this.value;
		}

		/** 
		 * 获取映射对象属性名称
		 * 
		 * @return {@code  Short}
		 */
		@Override
		public final String getProperty()
		{
			return this.property;
		}

		/** 
		 * 获取字段显示名称(数据库字段注释)
		 * 
		 * @return {@code  String}
		 */
		@Override
		public final String getShow()
		{
			return this.show;
		}

		/** 
		 * 
		 * @return {@code  String}
		 */
		@Override
		public String toString()
		{
			return this.value;
		}
	}
}
/* Honey v3.1 Test - version:4 - OriginalChecksum:Bce7108ad4e66cd7b1ac9b39f164920c6 (do not edit this line) */
